# FreeCAD命令示例

App.getDocument('Unnamed').getObject('Sketch').addExternal("BaseFeature", "Edge235")

Gui.Selection.getSelectionEx()[0].SubObjects[0].countElement('Edge')

Gui.Selection.getSelectionEx()[0].SubObjects[0].OuterWire.OrderedVertexes[0].Z



# 开始编辑草图
ActiveSketch = App.getDocument('Unnamed').getObject('Sketch')
tv = Show.TempoVis(App.ActiveDocument, tag=ActiveSketch.ViewObject.TypeId)
ActiveSketch.ViewObject.TempoVis = tv
if ActiveSketch.ViewObject.EditingWorkbench:
    tv.activateWorkbench(ActiveSketch.ViewObject.EditingWorkbench)
if ActiveSketch.ViewObject.HideDependent:
    tv.hide(tv.get_all_dependent(App.getDocument('Unnamed').getObject('Body'), 'Sketch.'))
if ActiveSketch.ViewObject.ShowSupport:
    tv.show([ref[0] for ref in ActiveSketch.Support if not ref[0].isDerivedFrom("PartDesign::Plane")])
if ActiveSketch.ViewObject.ShowLinks:
    tv.show([ref[0] for ref in ActiveSketch.ExternalGeometry])
tv.hide(ActiveSketch)
del (tv)
del (ActiveSketch)

ActiveSketch = App.getDocument('Unnamed').getObject('Sketch')
if ActiveSketch.ViewObject.RestoreCamera:
    ActiveSketch.ViewObject.TempoVis.saveCamera()

# 退出编辑草图
Gui.getDocument('Unnamed').resetEdit()
App.ActiveDocument.recompute()
ActiveSketch = App.getDocument('Unnamed').getObject('Sketch')
tv = ActiveSketch.ViewObject.TempoVis
if tv:
    tv.restore()
ActiveSketch.ViewObject.TempoVis = None
del (tv)
del (ActiveSketch)

# Gui.Selection.addSelection('Unnamed','Body','Sketch.')
App.getDocument('Unnamed').recompute()


# 执行完若不显示，应recompute()
App.ActiveDocument.recompute()

# 显示草图中点的实际坐标（注：经检查无效）
Gui.Selection.clearSelection()
Gui.Selection.addSelection('Unnamed','Body','Sketch.RootPoint',)
Gui.Selection.getSelectionEx()[0].PickedPoints[0]

# 选草图上的点
# >>> sel = Gui.Selection.getSelectionEx()[0]
# >>> sel.FullName
# "(App.getDocument('Unnamed').getObject('Sketch'),['Vertex1',])"
# (App.getDocument('Unnamed').getObject('Sketch'),['Vertex1',])

>>> sel.SubElementNames
('Vertex1',)